The use of literals (primitive values such as strings, numbers, booleans, etc.) for promise rejection is generally discouraged. While it is
syntactically valid to provide literals as a rejected promise value, it is considered best practice to use instances of the Error class or its
subclasses instead.
Using an instance of the Error class allows you to provide more meaningful information about the error. The Error class and its subclasses provide
properties such as message and stack that can be used to convey useful details about the error, such as a description of the problem, the context in
which it occurred, or a stack trace for debugging.
new Promise(function(resolve, reject) {
reject(); // Noncompliant: use Error object to provide rejection reason
});
new Promise(function(resolve, reject) {
reject('Something went wrong'); // Noncompliant: use Error object instead of literal
});
To fix your code provide an instanse of the Error class to the promise reject function.
new Promise(function(resolve, reject) {
reject(new Error('Network timeout'));
});
new Promise(function(resolve, reject) {
reject(new Error('Something went wrong'));
});